﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Demo</title>
	<!-- 请勿在项目正式环境中引用该 layui.css 地址 -->
	<link href="//unpkg.com/layui@2.9.20/dist/css/layui.css" rel="stylesheet">
</head>
<body class="layui-padding-3">
	<form class="layui-form" action="">
		<div class="layui-form-item">
			<label class="layui-form-label">部门名称:</label>
			<div class="layui-input-block">
				<input type="text" Id="orgName" lay-verify="required" placeholder="部门名称" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">部门编码:</label>
			<div class="layui-input-block">
				<input type="text" Id="orgCode" lay-verify="required" placeholder="部门编码" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">父分类:</label>

		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button type="submit" class="layui-btn" onclick="Add()">保存</button>
				<button type="reset" class="layui-btn layui-btn-primary">关闭</button>
			</div>
		</div>

	</form>

	<!-- 请勿在项目正式环境中引用该 layui.js 地址 -->
	<script src="//unpkg.com/layui@2.9.20/dist/layui.js"></script> 
</body>
</html>
<script>
	var form = layui.form;
	var $ = layui.jquery;
	function Add() {
		var data = {
		  orgName: $("#orgName").val(),
			orgCode: $("#orgCode").val(),
			parentId: 0,
			remark: "备注好好好",
			createId: 1,
			createName: "罗翔",
			createDate:new Date().toISOString("YYYY - MM - DD HH:mm:ss")
		};
		console.log(JSON.stringify(data));
		$.ajax({
			url: '@ViewBag.Keep' + "/api/Department/DepartmentCreate",
            type: "POST",
            dataType: "json",
            contentType: "application/json",
			data: JSON.stringify(data),
            success: function (data) {
				layer.msg(data);
				
            }
		})
		 
	}
</script>